#_*_ reading utf-8 _*_
# 开发团队： 智能引擎
# 开发人员： sen
# 开发时间： 2021/7/10
# 文件名称： get_hsv_point_data.py
# 开发工具： PyCharm

import cv2

# 读取图片并缩放方便显示
img = cv2.imread('demo/72_out.png')
height, width = img.shape[:2]
size = (int(width * 0.2), int(height * 0.2))
# 缩放
img = cv2.resize(img, size, interpolation=cv2.INTER_AREA)

# BGR转化为HSV
HSV = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)

# 鼠标点击响应事件
def getposHsv(event, x, y, flags, param):
    if event == cv2.EVENT_LBUTTONDOWN:
        print("HSV is", HSV[y, x])


def getposBgr(event, x, y, flags, param):
    if event == cv2.EVENT_LBUTTONDOWN:
        print("Bgr is", img[y, x])


cv2.imshow("imageHSV", HSV)
cv2.imshow('image', img)
cv2.setMouseCallback("imageHSV", getposHsv)
cv2.setMouseCallback("image", getposBgr)
cv2.waitKey(0)